/* eslint-disable camelcase,@typescript-eslint/no-unused-vars */ // DO NOT EDIT THIS FILE. AUTO-GENERATED BY mobiletto-orm-typedef-gen import { H3Event, H3Error } from "h3"; import { MobilettoOrmSyncError } from "mobiletto-orm-typedef"; export default defineEventHandler(async (event: H3Event) => { return await filterErrors(event, "library.delete", async (event: H3Event) => { return await requireAdminAccountObject(event, "library.delete", async (event: H3Event, session, account) => { const libraryRepo = libraryRepository(); const id = event?.context?.params?.id; if (!id) throw notFound(libraryRepo.typeDef.idFieldName()); try { const library_by_id = await libraryRepo.safeFindById(id); if (library_by_id) { return await libraryRepo.remove(library_by_id); } } catch (e) { if (e instanceof H3Error) throw e; if (e instanceof MobilettoOrmSyncError) { logger.warn(`library.delete: sync error: ${e}`); throw conflict(); } logger.error(`library.delete: unexpected error: ${e}`); throw serverError(); } throw notFound(id); }); }); });